package ParsingSys;

/**
 *
 * @author Lahza
 */
import java.util.ArrayList;

public class Value {
	private String name;
	private ArrayList<Value> dependencies = new ArrayList<Value>();


	/**
	 * Constructor of Value class
	 */
	public Value() {
	}

	/**
	 * Value Constructor that receives the name 
	 * @param name
	 */
	public Value(String name) {
		this.name = name;
	}

	
	/**
	 * Function to add a value
	 * @param value
	 */
	public void addDependency(Value value) {
		//search before adding a dependency
		boolean exists = false;
		for(Value v : dependencies){
			if (v.getName().compareTo(value.getName()) == 0)
				exists = true;
		}
		if (!exists)
			dependencies.add(value);
	}

	/**
	 * Return the name of Value
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * Get all dependencies for Value
	 * @return
	 */
	public ArrayList<Value> getDependencies() {
		return dependencies;
	}
	
	
	public String toString(){
		String description = name+":";
		for(Value d : dependencies){
			description += d.getName()+",";
		}
		return description;
	}
}
